<template>
  <section class="page">
    <headerbar>通知消息</headerbar>

    <section class="inner-content">
      <section class="detail">
        <h1 class="title" v-if="data.msgTitle">{{data.msgTitle}}</h1>
        <h1 class="title" v-else="">通知消息</h1>
        <p class="date">{{getTime(data.createTime)}} <span class="pull-right" v-if="data.sender">发送者：{{data.sender}}</span></p>
        <p class="line"></p>
        <div class="cont-text">
          {{data.content}}
        </div>
<!--        <p v-if="isParty(data)" @click="goDetail(data)" class="party-detail">查看详情 > ></p>-->
      </section>
    </section>
  </section>
</template>

<script>
  import tools from '@/utils/tools'
  import api from '@/common/config/api'
  import loginService from '@/service/loginService'
  import moment from 'moment'

  export default {
    name: 'noticeNotice',
    data () {
      return {
        fn: tools,
        data: {},
        msgId: '',
        files: [],
        attachmentList: [],
        detail: {}
      }
    },
    created () {
      // this.msgId = this.$route.params.msgId

      this.data = this.$store.state.noticeNewDetail
      this.loadData()
      // this.data = JSON.parse(this.detail.content)
      // this.isRead()
    },
    methods: {
      loadData () {
        let data = {
          loginId: '3750',
          msgId: this.msgId
        }
        console.log(' this.detail ', this.data )
        // this.fetchService.nodeMsgDetail(data).then(res => {
        //   if (res.code !== 200) {
        //     return tools.tip(res.message)
        //   }
        //   this.data = res.data
        //   this.files = this.data.annexList
        //   if (this.data.readResult === '0') {
        //     this.optNodeMsgRead()
        //   }
        //   // if (this.data.feedResult && this.data.feedResult === '0') {
        //   if (this.data.feedBack === '1' && this.$store.state.showFeedback) {
        //     this.$store.state.showFeedback = false
        //     this.showDialog()
        //   }
        //   console.log('---------this.data.annexList=', this.data.annexList.length)
        // })
      },
      getTime (createTime) {
        return moment(createTime).format('YYYY年MM月DD日 HH:mm:ss')
      },
      getDictValue () {
        let data={
          catKey:'GBZX',
          treeKey:'XSXG'
        }
        this.fetchService.dictValue(data).then(res => {
          console.log('this.fetchService.dictValue',res.data)
          if(res.code === 0){
            this.getDict=res.data
          }
        })
      },
      isParty(data){//判断是否为党务的数据
        if(data.category.toLowerCase().indexOf('party')!=-1){
          return true
        }
        return false
      },
      showImg (fileId) {
        let fileUrl = this.tools.getImgUrl(fileId)
        // let fileUrl = api.download + fileId + '?access_token=c4bd1b3942f3c2acd7657cbd0b5d952f'
        console.log('-------------fileUrl=', fileUrl)
        return fileUrl
      },
      go () {
        this.$router.push({path: `/feedback/${this.data.id}`})
      },
      isImage (fileName) {
        let arrExt = fileName.split('.')
        return 'PNG,JPG,JPEG,BMP,GIF'.split(',').indexOf(arrExt[arrExt.length - 1].toUpperCase()) > -1
      },
      downLoadFile (item) {
        console.log("item={}", item)
        let url = this.tools.getImgUrl(item.fileId)
        if (window.android && window.android.downloadFile) {
          window.android.downloadFile(url, item.fileName)
        }
      },
      showImagePreview (item) {
        if (item.fileId.length < 1) {
          return false
        }
        let fileUrl = this.tools.getImgUrl(item.fileId)
        item.url = fileUrl
        let imgs = [fileUrl]
        this.$createImagePreview({
          initialIndex: 0,
          imgs: imgs
        }, (h) => {
          return h('div', {
            class: {
              'image-preview-custom-header': false
            },
            slot: 'header'
          }, '')
        }).show()
      },
      showDialog () {
        let me = this
        this.$createDialog({
          type: 'confirm',
          icon: '',
          title: '温馨提示',
          content: '该通知需要反馈给发送方信息',
          confirmBtn: {
            text: '反馈',
            active: true,
            disabled: false,
            href: 'javascript:;'
          },
          onConfirm: () => {
            me.goFeedback()
          }
        }).show()
      },
      goFeedback () {
        this.$createFeedbackDialog({
          $props: {
            msgId: this.msgId,
            msgType: this.data.msgType
          }
        })
//        this.go()
      },
      isRead () {
        if (window.android && window.android.updateRead) {
          window.android.updateRead(this.detail.id)
        }
      },
      getSender (data) {
        let content = JSON.parse(data.content)
        return content.sender
      },
      goDetail (data) {
        // this.$store.state.showFeedback = true
        this.$router.push({path: `/noticeNoticeDetail/${data.businessId}/0`})
      },
    }
  }
</script>

<style scoped>
 .party-detail{
   color: #0f9ceb;
   line-height: 2em;
   font-size: 16PX;
 }
 .detail .cont-text {
   font-family: dang,PingFang SC,miui,system-ui,-apple-system,BlinkMacSy;
 }
</style>
